<template>
        <div class="newsinfo-container">
                <!-- 大标题 -->
                <h3 class="title">{{ newsinfo.title }}</h3>
                <!-- 子标题 -->
                <p class="subtitle">
                  <span>发表时间：{{ newsinfo.add_time | dataFormat}}</span>
                  <span>点击：{{ newsinfo.click }}次</span>
                </p>
            
                <hr>
            
                <!-- 内容区域 -->
                <div class="content" v-html="newsinfo.content"></div>
            
                <!-- 评论子组件区域 -->
                <component-box :id="id"></component-box>
              </div>
</template>


<script>
    //  导入评论的自组件
    import component from '../UserReviews/UserReviews.vue'

    export default {
        data() {
            return {
                id: this.$route.params.id,
                newsinfo: {}
            }
        },
        created() {
            this.getnewsInfo()
        },
        methods: {
            getnewsInfo() {
                //获取轮播图的方法
                this.axios.get('/api/getnew/' + this.id).then(reslult => {
                    // console.log(reslult)

                    if (reslult.data.status === 0) {
                        this.newsinfo = reslult.data.message[0]
                    } else {
                        Toast('图片加载失败')
                    }
                })
            }
        },
        components: {
            'component-box': component
        }
    }
</script>


<style lang="scss" scoped>
    .newsinfo-container {
        padding: 0 10px;
        .title {
            text-align: center;
            color: red;
            font-size: 16px;
            margin: 15px 0;
        }
        .subtitle {
            color: #226aff;
            font-size: 13px;
            display: flex;
            justify-content: space-between;
        }
        .content {
            /deep/ img {
                width: 100%;
                height: 100%;
            }
        }
    }
</style>